
SwitchUser.setup do |config|
  config.provider = :session
  config.available_users = { user: -> { User.joins(:user_roles).joins(:roles).where("roles.name = ?", 'designer').distinct } }
  config.available_users_identifiers = { user: :id }
  config.available_users_names = { user: :mobile }
  config.controller_guard = ->(current_user, request) { current_user && current_user.is_admin? }
  config.view_guard = ->(current_user, request) { current_user && current_user.is_admin? }
  config.redirect_path = ->(request, params) { params[:scope_identifier] =~ /^admin/ ? '/admin' : '/' }
  config.helper_with_guest = false
end

